765B - Code obfuscation - CodeForces Solution


greedy implementation strings *1100

Please click on ads to support us..

Python Code:

king=input()


st=sorted(set(king),key=king.index)
for got in range(len(st)):



    if st[got]!=chr(97+got):exit(print('NO'))
print('YES')
	  	   		    			 	  				 		  	

C++ Code:

#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    int actual = 'a';
    for (int i = 0; i < s.length(); i++) {
        char letra = s[i];
        if (letra > actual){
            cout << "NO" << endl;
            return 0;
        } else if (letra == actual) {
            actual++;
        }
    }
    cout << "YES" << endl;
    return 0;
}
 			  					 			 	 		 	 	   	 	


Comments

Submit
0 Comments
More Questions

Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array